<?php

require_once '../include.php';

$arr=$_POST;
$uid=$_POST['uid'];
unset($arr['password2']);
unset($arr['uid']);
// var_dump($arr);
// foreach ($arr as $row):
//     echo $row."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
// endforeach;

$PG = new pgsql("gis24.jlu3s.com", "23456", "ccly", "sde", "GIScontest2024");  
$PG->connect();
if(!$PG){  
    $db_error = "无法连接到PostGreSQL数据库！";  
    echo $db_error;   
}else{ 
    $q1 = "SELECT * FROM public.user where username='{$arr['username']}'";
    $r1 = $PG->query($q1); 
    // var_dump($r1);
    $r11 = $PG->affectedRows();
    // echo $r11;
    // var_dump($r11);
    if($r11>0){        
        $r = $PG->update("public.user", $arr,"uid='{$uid}'");
        if($r>0){            
            alertMes("修改成功！","userList.php");       
        }else{
            alertMes("操作失败，请重试","userList.php"); 
        }
    }
}